/*    */ package blockbuster.utils.texture;
/*    */ 
/*    */ import java.awt.image.BufferedImage;
/*    */ import java.io.Closeable;
/*    */ import java.io.IOException;
/*    */ import java.nio.ByteBuffer;
/*    */ import net.minecraft.client.renderer.GLAllocation;
/*    */ import net.minecraft.client.renderer.GlStateManager;
/*    */ import net.minecraft.client.renderer.texture.SimpleTexture;
/*    */ import net.minecraft.client.renderer.texture.TextureUtil;
/*    */ import net.minecraft.client.resources.IResource;
/*    */ import net.minecraft.client.resources.IResourceManager;
/*    */ import net.minecraft.util.ResourceLocation;
/*    */ import net.minecraftforge.fml.relauncher.Side;
/*    */ import net.minecraftforge.fml.relauncher.SideOnly;
/*    */ import org.apache.commons.io.IOUtils;
/*    */ import org.lwjgl.opengl.GL11;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @SideOnly(Side.CLIENT)
/*    */ public class MipmapTexture
/*    */   extends SimpleTexture
/*    */ {
/*    */   public static ByteBuffer bytesFromBuffer(BufferedImage image) {
/* 35 */     int w = image.getWidth();
/* 36 */     int h = image.getHeight();
/*    */     
/* 38 */     ByteBuffer buffer = GLAllocation.func_74524_c(w * h * 4);
/* 39 */     int[] pixels = new int[w * h];
/*    */     
/* 41 */     image.getRGB(0, 0, w, h, pixels, 0, w);
/*    */     
/* 43 */     for (int y = 0; y < h; y++) {
/*    */       
/* 45 */       for (int x = 0; x < w; x++) {
/*    */         
/* 47 */         int pixel = pixels[y * w + x];
/*    */         
/* 49 */         buffer.put((byte)(pixel >> 16 & 0xFF));
/* 50 */         buffer.put((byte)(pixel >> 8 & 0xFF));
/* 51 */         buffer.put((byte)(pixel & 0xFF));
/* 52 */         buffer.put((byte)(pixel >> 24 & 0xFF));
/*    */       } 
/*    */     } 
/*    */     
/* 56 */     buffer.flip();
/*    */     
/* 58 */     return buffer;
/*    */   }
/*    */ 
/*    */   
/*    */   public MipmapTexture(ResourceLocation textureResourceLocation) {
/* 63 */     super(textureResourceLocation);
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public void func_110551_a(IResourceManager resourceManager) throws IOException {
/* 69 */     IResource resource = null;
/*    */ 
/*    */     
/*    */     try {
/* 73 */       resource = resourceManager.func_110536_a(this.field_110568_b);
/* 74 */       BufferedImage image = TextureUtil.func_177053_a(resource.func_110527_b());
/*    */       
/* 76 */       int id = func_110552_b();
/* 77 */       int w = image.getWidth();
/* 78 */       int h = image.getHeight();
/*    */       
/* 80 */       GlStateManager.func_179144_i(id);
/* 81 */       GlStateManager.func_187421_b(3553, 33082, 0);
/* 82 */       GlStateManager.func_187421_b(3553, 33083, 3);
/* 83 */       GlStateManager.func_187421_b(3553, 33085, 3);
/* 84 */       GlStateManager.func_187403_b(3553, 34049, 0.0F);
/* 85 */       GlStateManager.func_187403_b(3553, 33169, 1.0F);
/* 86 */       GlStateManager.func_187403_b(3553, 10241, 9986.0F);
/* 87 */       GlStateManager.func_187403_b(3553, 10240, 9986.0F);
/*    */       
/* 89 */       GL11.glTexImage2D(3553, 0, 32856, w, h, 0, 6408, 5121, bytesFromBuffer(image));
/*    */     }
/*    */     finally {
/*    */       
/* 93 */       IOUtils.closeQuietly((Closeable)resource);
/*    */     } 
/*    */   }
/*    */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\blockbuste\\utils\texture\MipmapTexture.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */